<%--
    Document   : relatorioFaltaAnalitico
    Created on : 06/09/2010, 08:08:18
    Author     : Thiago
--%>

<%@page import="java.net.URLEncoder"%>
<%@page import="crypt.Crypt"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="bo.*"%>
<%@page import="beans.*"%>
<%@page import="autenticacao.Sessao"%>
<%

            String moduleId = "12";
            Crypt crypt = new Crypt();
            try {
                crypt.setKey(crypt.Decifragem((String)session.getAttribute("userPhrase")));
                String desafio = crypt.Cifragem(moduleId + "@" + ferramentas.DataHora.formatarDataHora(ferramentas.DataHora.retornarDataHoraAtual(), ferramentas.DataHora.DATE_TIME_FORMAT));
                if (!(new Sessao(session).validarSessao(desafio))) {
                    response.sendRedirect("/" + request.getContextPath());
                }
            } catch (Exception e) {
                response.sendRedirect("/" + request.getContextPath());
            }

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Gestor Operacional</title>
        <link href="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>css/style.css" type="text/css" rel="stylesheet"/>
        <link href="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>css/table.css" type="text/css" rel="stylesheet"/>
        <link href="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>css/anytime.css" rel="stylesheet" type="text/css"/>
        <script type="text/javascript" src="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>scripts/jquery.js"></script>
        <script type="text/javascript" src="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>scripts/anytime.js"></script>
        <script type="text/javascript" src="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>scripts/anytimetz.js"></script>
        <script type="text/javascript" src="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>scripts/table.js"></script>

        <script type="text/javascript" src="<%out.print(new String(request.getRequestURL()).split("pages")[0]);%>scripts/ddpowerzoomer.js"></script>

        <script type="text/javascript">
            jQuery(document).ready(function($){ //fire on DOM ready
                $('#myimage').addpowerzoom({
                        defaultpower: 2,
                        powerrange: [2,5],
                        largeimage: null,
                        magnifiersize: [400,300] //<--no comma following last option!
                })
            })
        </script>

    </head>
    <body>
        <table width="100%">
            <tr>
                <td>
                    <jsp:include page = "../menu.jsp" flush = "true"/>
                </td>
            </tr>

            <tr align="center">
                <td><br/><br/>
                    <form name="form1" action="graficoProducaoMediaPorProcesso.jsp" method="post">
                        <input type="hidden" name="exibirGrafico" value="true">
                        <table border="1" cellspacing="0" width="430" bgcolor="#FFFFFF">
                            <tr>
                                <td width="105">Colaborador:</td>
                                <td align="center">
                                    <select name="colaborador" size="1">
                                        <option value="" selected>Todos</option>
                                        <%
                                                    ArrayList<Colaborador> alc = null;
                                                    try {
                                                        alc = new ColaboradorBO().recuperarColaborador(null);
                                                    } catch (Exception e) {
                                                        out.println(e.getMessage());
                                                    }
                                                    if (alc != null) {
                                                        for (int i = 0; i < alc.size(); i++) {
                                                            out.println("<option value=\"" + alc.get(i).getMatricula() + "\">" + alc.get(i).getMatricula() + " - " + alc.get(i).getNome() + "</option>");
                                                        }
                                                    }
                                        %>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>Cargo:</td>
                                <td align="center">
                                    <select name="cargo" size="1">
                                        <option value="" selected>Todos</option>
                                        <%
                                                    ArrayList<Cargo> cargos = null;
                                                    try {
                                                        cargos = new CargoBO().recuperarCargo(null);
                                                    } catch (Exception e) {
                                                        out.println(e.getMessage());
                                                    }
                                                    if (cargos != null) {
                                                        for (int i = 0; i < cargos.size(); i++) {
                                                            out.println("<option value=\"" + cargos.get(i).getId() + "\">" + cargos.get(i).getDescricao() + "</option>");
                                                        }
                                                    }
                                        %>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>Processo:</td>
                                <td align="center">
                                    <select name="processo" size ="1">
                                        <option value="" selected>Todos</option>
                                        <%
                                                    ArrayList<Processo> alp = null;
                                                    try {
                                                        alp = new ProcessoBO().recuperarProcessos(null);
                                                    } catch (Exception e) {
                                                        out.println(e.getMessage());
                                                    }
                                                    if (alp != null) {
                                                        for (int i = 0; i < alp.size(); i++) {
                                                            out.println("<option value=\"" + alp.get(i).getId() + "\">" + alp.get(i).getDescricao() + "</option>");
                                                        }
                                                    }

                                        %>
                                    </select>
                                </td>
                            </tr>
                            <tr><td>Site:</td>
                                <td align="center">
                                    <select name="site" size="1">
                                        <option value="" selected>Todos</option>
                                        <%
                                                    ArrayList<Site> als = null;
                                                    try {
                                                        als = new SiteBO().recuperarSite(null);
                                                    } catch (Exception e) {
                                                        out.println(e.getMessage());
                                                    }
                                                    if (als != null) {
                                                        for (int i = 0; i < als.size(); i++) {
                                                            out.println("<option value=\"" + als.get(i).getId() + "\">" + als.get(i).getDescricao() + "</option>");
                                                        }
                                                    }

                                        %>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>Data Inicial:</td>
                                <td align="center">
                                    <input id="data" name="data" type="text" maxlength="10" size="10">
                                    <script type="text/javascript">
                                        AnyTime.picker( "data",
                                        { format: "%d/%m/%z", firstDOW: 0 } );
                                    </script>
                                </td>
                            </tr>
                            <tr>
                                <td>Data Final:</td>
                                <td align="center">
                                    <input id="dataFim" name="dataFim" type="text" maxlength="10" size="10">
                                    <script type="text/javascript">
                                        AnyTime.picker( "dataFim",
                                        { format: "%d/%m/%z", firstDOW: 0 } );
                                    </script>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <input type="submit">
                                </td>
                            </tr>
                        </table>
                    </form>
                </td>
            </tr>
            <tr>
                <td align="center">
                    <%
                                if ((request.getParameter("exibirGrafico") != null) && request.getParameter("exibirGrafico").equals("true")) {
                                    out.println("<br/><br/><hr><br/><br/><table><tr><td align=\"center\">");
                                    if ((request.getParameter("data") != null) && (request.getParameter("data").length() != 0)) {
                                        String desafio = crypt.Cifragem(moduleId + "@" + ferramentas.DataHora.formatarDataHora(ferramentas.DataHora.retornarDataHoraAtual(), ferramentas.DataHora.DATE_TIME_FORMAT));
                                        out.println("<IMG id=\"myimage\" SRC=\"../ChartGenerator?type=ProducaoMediaPorProcesso&desafio="+URLEncoder.encode(desafio,"UTF-8")+"&data=" + request.getParameter("data") + "&dataFim=" + request.getParameter("dataFim") + "&cargo=" + request.getParameter("cargo") + "&processo=" + request.getParameter("processo") + "&colaborador=" + request.getParameter("colaborador") + "&site=" + request.getParameter("site") + "\" BORDER=1/>");
                                    } else {
                                        out.println("Por favor, especifique um período.");
                                    }
                                    out.println("</td></tr></table>");
                                }
                    %>
                </td>
            </tr>
        </table>
    </body>
</html>